package com.fastCms.business.bim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.bim.daos.AreaDeviceRelMapper;
import com.fastCms.business.bim.pojo.entity.AreaDeviceRel;
import com.fastCms.business.bim.service.AreaDeviceRelService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 区域所关联的设备 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2021-04-07
 */
@Service
public class AreaDeviceRelServiceImpl extends ServiceImpl<AreaDeviceRelMapper, AreaDeviceRel> implements AreaDeviceRelService {

    @Override
    public AreaDeviceRel findByAreaIdAndDeviceId(Integer areaId, Integer deviceId) {
        QueryWrapper<AreaDeviceRel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("area_id", areaId);
        queryWrapper.eq("device_id", deviceId);
        return getOne(queryWrapper);
    }
}
